package crud.service.impl;

import crud.dao.UserInfoDao;
import crud.dao.pojo.UserInfo;
import crud.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service("userInfoService")     //标记业务逻辑层的类
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)  //标记一个事物, 并指定传播行为和隔离级别
public class UserInfoServiceImpl implements UserInfoService {
    @Autowired
    UserInfoDao userInfoDao;

    @Override
    public void addUserInfo(UserInfo userInfo) {
        userInfoDao.add(userInfo);
    }

    @Override
    public void updateUserInfo(UserInfo userInfo) {
        userInfoDao.update(userInfo);
    }
    @Override
    public void deleteUserInfo(UserInfo userInfo) {
        userInfoDao.delete(userInfo);
    }
    @Override
    public Integer count() {
        return userInfoDao.count();
    }

    @Override
    public List<UserInfo> allUsers(){
        return userInfoDao.allUsers();
    }
}
